package KUtilities;

import java.awt.Dimension;
import java.awt.Point;

import javax.swing.JComponent;
import javax.swing.Spring;
import javax.swing.SpringLayout;

public class KSpringAttributes extends SpringLayout{

	/**
	 * Gets the <code>width spring</code> of the specified <code>component</code>
     * @param   component : component to get width
	 */
	public Spring getWidth(JComponent component)
	{
		return getConstraints(component).getWidth();
	}
	
	/**
	 * Sets the <code>width</code> of the specified <code>component</code>
     * @param   component : component to set new width
     * @param   width : new width of the component
	 */
	public void setWidth(JComponent component,int width)
	{
		setWidth(component,Spring.constant(width));
	}
	
	/**
	 * Sets the <code>width</code> of the specified <code>component</code> based on specified minimum, preferred and maximum values
     * @param   component : component to set new width
     * @param   min : minimum width of the component
     * @param   pref : preferred width of the component
     * @param   max : maximum width of the component
	 */
	public void setWidth(JComponent component,int min,int pref,int max)
	{
		setWidth(component,Spring.constant(min,pref,max));
	}
	
	/**
	 * Sets the <code>width spring</code> of the specified <code>component</code>
     * @param   component : component to set new width
     * @param   width : new width spring of the component
	 */
	public void setWidth(JComponent component,Spring width)
	{
		getConstraints(component).setWidth(width);
	}

	/**
	 * Gets the <code>height spring</code> of the specified <code>component</code>
     * @param   component : component to get height
	 */
	public Spring getHeight(JComponent component)
	{
		return getConstraints(component).getHeight();
	}
	
	/**
	 * Sets the <code>height</code> of the specified <code>component</code>
     * @param   component : component to set new height
     * @param   height : new height of the component
	 */
	public void setHeight(JComponent component,int height)
	{
		setHeight(component,Spring.constant(height));
	}
	
	/**
	 * Sets the <code>height</code> of the specified <code>component</code> based on specified minimum, preferred and maximum values
     * @param   component : component to set new height
     * @param   min : minimum height of the component
     * @param   pref : preferred height of the component
     * @param   max : maximum height of the component
	 */
	public void setHeight(JComponent component,int min,int pref,int max)
	{
		setHeight(component,Spring.constant(min,pref,max));
	}
	
	/**
	 * Sets the <code>height spring</code> of the specified <code>component</code>
     * @param   component : Component to set new height
     * @param   height : new height spring of the Component
	 */
	public void setHeight(JComponent component,Spring height)
	{
		getConstraints(component).setHeight(height);
	}
	
	/**
	 * Sets the <code>width</code> and <code>height</code> of the specified <code>component</code>
     * @param   component : component to resize
     * @param   width : new width of the Component
     * @param   height : new height of the Component
	 */
	public void setSize(JComponent component,int width,int height)
	{
		setWidth(component,width);
		setHeight(component,height);
	}
	
	/**
	 * Sets the <code>size</code> and <code>height</code> of the specified <code>component</code>
     * @param   component : component to resize
     * @param   size : new dimension of the Component
	 */
	public void setSize(JComponent component,Dimension size)
	{
		setSize(component,size.width,size.height);
	}
	
	/**
	 * Sets the <code>width</code> and <code>height</code> of the specified <code>component</code>
     * @param   component : component to resize
     * @param   width : new width spring of the Component
     * @param   height : new height spring of the Component
	 */
	public void setSize(JComponent component,int minWidth,int prefWidth,int maxWidth,int minHeight,int prefHeight,int maxHeight)
	{
		setWidth(component,minWidth,prefWidth,maxWidth);
		setHeight(component,minHeight,prefHeight,maxHeight);
	}
	
	/**
	 * Sets the <code>width</code> and <code>height</code> of the specified <code>component</code>
     * @param   component : component to resize
     * @param   width : new width spring of the Component
     * @param   height : new height spring of the Component
	 */
	public void setSize(JComponent component,Spring width,Spring height)
	{
		setWidth(component,width);
		setHeight(component,height);
	}
	
	/**
	 * Gets the <code>x-coordinate spring</code> of the specified <code>component</code>
     * @param   component : component to find x-coordinate
	 */
	public Spring getX(JComponent component)
	{
		return getConstraints(component).getX();
	}
	
	/**
	 * Sets the <code>x-coordinate</code> of the specified <code>component</code>
     * @param   component : component to relocate
     * @param   x : x-coordinate of new location
     */
	public void setX(JComponent component,int x)
	{
		setX(component,Spring.constant(x));
	}
	
	/**
	 * Sets the <code>x-coordinate</code> of the specified <code>component</code> based on specified minimum, preferred and maximum values
     * @param   component : component to relocate
	 * @param   min : minimum x-coordinate of new location
     * @param   pref : preferred x-coordinate of new location
     * @param   max : maximum x-coordinate of new location
	 */
	public void setX(JComponent component,int min,int pref,int max)
	{
		setX(component,Spring.constant(min,pref,max));
	}
	
	/**
	 * Sets the <code>x-coordinate spring</code> of the specified <code>component</code>
     * @param   component : component to relocate
     * @param   x : x-coordinate spring of new location
	 */
	public void setX(JComponent component,Spring x)
	{
		getConstraints(component).setX(x);
	}
	
	/**
	 * Gets the <code>y-coordinate spring</code> of the specified <code>component</code>
     * @param   component : component to find y-coordinate
	 */
	public Spring getY(JComponent component)
	{
		return getConstraints(component).getY();
	}
	
	/**
	 * Sets the <code>y-coordinate</code> of the specified <code>component</code>
     * @param   component : component to relocate
     * @param   y : y-coordinate of new location
     */
	public void setY(JComponent component,int y)
	{
		setY(component,Spring.constant(y));
	}
	
	/**
	 * Sets the <code>y-coordinate</code> of the specified <code>component</code> based on specified minimum, preferred and maximum values
     * @param   component : component to relocate
	 * @param   min : minimum y-coordinate of new location
     * @param   pref : preferred y-coordinate of new location
     * @param   max : maximum y-coordinate of new location
	 */
	public void setY(JComponent component,int min,int pref,int max)
	{
		setY(component,Spring.constant(min,pref,max));
	}
	
	/**
	 * Sets the <code>y-coordinate spring</code> of the specified <code>component</code>
     * @param   component : component to relocate
     * @param   y : y-coordinate spring of new location
	 */
	public void setY(JComponent component,Spring y)
	{
		getConstraints(component).setY(y);
	}

	/**
	 * Sets the <code>x-coordinate</code> and <code>y-coordinate</code> of the specified <code>component</code>
     * @param   component : component to relocate
     * @param 	x : x-coordinate of new location
     * @param   y : y-coordinate of new location
	 */
	public void setLocation(JComponent component,int x,int y)
	{
		setX(component,x);
		setY(component,y);
	}
	
	/**
	 * Sets the <code>location</code> of the specified <code>component</code>
     * @param   component : component to relocate
     * @param 	location : point of the new location
	 */
	public void setLocation(JComponent component,Point location)
	{
		setLocation(component,location.x,location.y);
	}
	
}
